// pages/minePage/cityNumber/cityNumber.js
const app = getApp()
Page({

    /**
     * 页面的初始数据
     */
    data: {
        uid: '',
        cityInfoArr: [],
        loading: true,
        loadingAll: false,
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function(options) {
        wx.setNavigationBarTitle({
            title: '城市·' + options.checkincitynum
        })
        this.setData({
            uid: options.uid
        })
        this.getCityInfo()
    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function() {

    },

    getCityInfo(e) {
        let _that = this
        wx.request({
            url: app.globalData.rootPath + `cjMap/getCheckinCityList`,
            method: "GET",
            header: {
                "content-type": "application/x-www-form-urlencoded"
            },
            data: {
                // authId: 'bcf82b6392f54843805253387e6985c0',
                authId: app.globalData.authId,
                uid: _that.data.uid || ''
            },
            success: function(res) {
                let checkintimeDay;
                if (res.data.errmsg == "输入页码超出范围") {
                    _that.setData({
                        loadingAll: true,
                        loading: false
                    })
                } else {
                    for (let i = 0; i < res.data.data.length; i++) {
                        checkintimeDay = res.data.data[i].checkintime.slice(8, 10) ? '/' + res.data.data[i].checkintime.slice(8, 10) : ''
                        res.data.data[i].checkintime = res.data.data[i].checkintime.slice(0, 4) + '/' + res.data.data[i].checkintime.slice(5, 7) + checkintimeDay
                        res.data.data[i].country = res.data.data[i].country == '中国' ? '' : '(' + res.data.data[i].country + ')'
                        _that.data.cityInfoArr.push(res.data.data[i])
                    }
                    _that.setData({
                        cityInfoArr: _that.data.cityInfoArr,
                        loadingAll: true,
                        loading: false
                    })
                }
            }
        });

    },
})